#ifndef __SENDER_H
#define __SENDER_H

#include<functional>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<unistd.h>
#include<arpa/inet.h>
#include<netinet/in.h>

#include<thread>
#include<chrono>

#include<pthread.h>

#include"timer.h"
#include"clock.h"
#include"color.h"

using namespace std;

#define HEADER_LINE 128
#define BUFF_LINE 512
#define BUFF_LINE_2 1024





/***************************************
			Class Sender
***************************************/
class Sender
{
public:
	Sender();
	~Sender();


	/*
	client
		Sender udp_cs;
		udp_cs.run_sender();
	*/
	void run_sender();
	void preset_sender();
	void start_sender();
	void end_sender();

	void stop_sender();

	//set header
	void set_header();

//private:

	char header[HEADER_LINE];
	char endbuf[BUFF_LINE];
	char buf[BUFF_LINE];

	bool sender_running ;


	//client
	int client_fd;
	struct sockaddr_in ser_addr;

	//server
	int server_port;
	int buf_send_line;
	//?
	//string server_ip = "10.0.16.2";	
	//remote server ip
	string server_ip = "82.157.129.44";	
	
	//local windows ip
	//string server_ip = "192.168.0.112";	

};

/***************************************
			Class SenderController
***************************************/
class SenderController
{
public:
	SenderController(){};
	~SenderController(){};
	static void sender_install( Sender *sender );
	static void sender_stop_sender();
	
//private:
	static Sender *sender_ptr;
};

//Sender *SenderController::udpCs_ptr = NULL;

/***************************************
			Class SenderThread
***************************************/
class SenderThread
{
public:
	/*
	thread
		run independent sender&receiver
	*/
	SenderThread();
	~SenderThread();
	void run_independent_sender();
	void wait_for_sender();

//private:
	Sender sender;
	thread *t_sender;
};


#endif
